package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.BasePrice;
import com.eling.elcms.travel.service.IBasePriceManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class BasePriceController extends BaseFormController{

	@Autowired
	private IBasePriceManager basePriceManager;
	
	@RequestMapping("/api/baseprice/save")
    @ResponseBody
	public BasePrice save(@ModelAttribute@ModelFilling BasePrice cond){
		return basePriceManager.save(cond);
	}
	
	@RequestMapping("/api/baseprice/{pkBasePrice}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkBasePrice){
		basePriceManager.remove(pkBasePrice);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/baseprice/query")
    @ResponseBody
	public List<BasePrice> query(@ModelAttribute BasePrice cond){
		return basePriceManager.query(cond);
	}
	
	@RequestMapping("/api/baseprice/getprice")
    @ResponseBody
	public BasePrice getPrice(){
		return basePriceManager.getPrice();
	}
	
	@RequestMapping("/api/baseprice/search*")
	@ResponseBody
	public List<BasePrice> search(@ModelAttribute SearchCondition sc,@ModelAttribute BasePrice cond){
		sc.setQueryCondition(cond);
		return basePriceManager.search(sc);
	}
}
